package com.ruoyi.project.module.releaseGroup.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.releaseGroup.domain.ReleaseGroup;
import com.ruoyi.project.module.releaseGroup.service.IReleaseGroupService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 发布属性组 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-12-06
 */
@Controller
@RequestMapping("/module/releaseGroup")
public class ReleaseGroupController extends BaseController
{
    private String prefix = "module/releaseGroup";
	
	@Autowired
	private IReleaseGroupService releaseGroupService;
	
	@RequiresPermissions("module:releaseGroup:view")
	@GetMapping()
	public String releaseGroup()
	{
	    return prefix + "/releaseGroup";
	}
	
	/**
	 * 查询发布属性组列表
	 */
	@RequiresPermissions("module:releaseGroup:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ReleaseGroup releaseGroup)
	{
		startPage();
        List<ReleaseGroup> list = releaseGroupService.selectReleaseGroupList(releaseGroup);
		return getDataTable(list);
	}
	
	/**
	 * 新增发布属性组
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存发布属性组
	 */
	@RequiresPermissions("module:releaseGroup:add")
	@Log(title = "发布属性组", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ReleaseGroup releaseGroup)
	{		
		return toAjax(releaseGroupService.insertReleaseGroup(releaseGroup));
	}

	/**
	 * 修改发布属性组
	 */
	@GetMapping("/edit/{configReleaseGroupId}")
	public String edit(@PathVariable("configReleaseGroupId") Long configReleaseGroupId, ModelMap mmap)
	{
		ReleaseGroup releaseGroup = releaseGroupService.selectReleaseGroupById(configReleaseGroupId);
		mmap.put("releaseGroup", releaseGroup);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存发布属性组
	 */
	@RequiresPermissions("module:releaseGroup:edit")
	@Log(title = "发布属性组", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ReleaseGroup releaseGroup)
	{		
		return toAjax(releaseGroupService.updateReleaseGroup(releaseGroup));
	}
	
	/**
	 * 删除发布属性组
	 */
	@RequiresPermissions("module:releaseGroup:remove")
	@Log(title = "发布属性组", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(releaseGroupService.deleteReleaseGroupByIds(ids));
	}
	
}
